#include"ShareMemory.hpp"
#include"Time.hpp"
#include"Fifo.hpp"
#include<string.h>
int main()
{
    shm.CreatShm();

    shm.AttachShm();
    std::cout << "server attach done" << std::endl;
    //sleep(3);

    //通信
    gpipe1.OpenPipeForRead();
    struct data *image = (struct data *)shm.GetAddr();
    while (true)
    {
        gpipe1.Wait();

        printf("status: %s\n", image->status);
        printf("lasttime: %s\n", image->lasttime);
        printf("image: %s\n", image->image);
        strcpy(image->status, "过期");
        gpipe2.Signal();
    }



    // char *strinfo = (char*)shm.GetAddr();
    // while(true)
    // {
    //     printf("%s\n",strinfo);
    //     sleep(1);
    // }

    shm.DetachShm();
    std::cout << "server detach done" << std::endl;
    //sleep(3);


    shm.DeleteShm();
    std::cout << "server delete done" << std::endl;
    //sleep(3);


    return 0;
}



// int main()
// {
//     //1.创建key，保证看到同一份内存的标识
//     //2.通过key创建共享内存 && 获取共享内存
//     //3.将共享内存挂接到自己的地址空间
//     //4.去关联，解除用户地址与共享内存间的映射联系
//     //删除共享内存
//    return 0;
// }